﻿using System;
using System.Collections.Generic;
using System.Text;

using Torch.WL.Entity.CleanChina;
using System.Data.SqlClient;
using System.Data;

namespace Torch.WL.DataAccess.CleanChina
{
    public class TbExpoAccess
    {
        public TbExpoAccess()
        {

        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TbExpoEntity GetModel(int expoId)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 * from Tb_Expo ");
            strSql.Append(" where expoId=@expoId");
            SqlParameter[] parameters = {
					new SqlParameter("@expoId", SqlDbType.Int,4)
			};
            parameters[0].Value = expoId;

            TbExpoEntity model = new TbExpoEntity();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TbExpoEntity DataRowToModel(DataRow row)
        {
            TbExpoEntity model = new TbExpoEntity();
            if (row != null)
            {
                if (row["expoId"] != null && row["expoId"].ToString() != "")
                {
                    model.expoId = int.Parse(row["expoId"].ToString());
                }
                if (row["logo"] != null)
                {
                    model.logo = row["logo"].ToString();
                }
                if (row["expoName"] != null)
                {
                    model.expoName = row["expoName"].ToString();
                }
                if (row["beginDate"] != null && row["beginDate"].ToString() != "")
                {
                    model.beginDate = DateTime.Parse(row["beginDate"].ToString());
                }
                if (row["endDate"] != null && row["endDate"].ToString() != "")
                {
                    model.endDate = DateTime.Parse(row["endDate"].ToString());
                }
                if (row["address"] != null)
                {
                    model.address = row["address"].ToString();
                }
                if (row["website"] != null)
                {
                    model.website = row["website"].ToString();
                }
                if (row["summary"] != null)
                {
                    model.summary = row["summary"].ToString();
                }
                if (row["howtoVisit"] != null)
                {
                    model.howtoVisit = row["howtoVisit"].ToString();
                }
                if (row["JiuDianZS"] != null)
                {
                    model.JiuDianZS = row["JiuDianZS"].ToString();
                }
                if (row["MianFeiBC"] != null)
                {
                    model.MianFeiBC = row["MianFeiBC"].ToString();
                }
                if (row["TingCheFW"] != null)
                {
                    model.TingCheFW = row["TingCheFW"].ToString();
                }
                if (row["CanYin"] != null)
                {
                    model.CanYin = row["CanYin"].ToString();
                }
                if (row["WangLuo"] != null)
                {
                    model.WangLuo = row["WangLuo"].ToString();
                }
                if (row["XiShouJ"] != null)
                {
                    model.XiShouJ = row["XiShouJ"].ToString();
                }
                if (row["LiPin"] != null)
                {
                    model.LiPin = row["LiPin"].ToString();
                }
                if (row["ZhuBanFBGS"] != null)
                {
                    model.ZhuBanFBGS = row["ZhuBanFBGS"].ToString();
                }
                if (row["VIPXXQ"] != null)
                {
                    model.VIPXXQ = row["VIPXXQ"].ToString();
                }
            }
            return model;
        }


    }
}
